if True:
    import sys
    import os
    sys.path.append(os.path.split(os.path.realpath(__file__))[0])
import sqlite_utils as sq
# 不加这一行则python不会把子目录加入import的范围


class carType(sq.SqTable, metaclass=sq.TableMeta):
    """此表用于存储车信息"""
    UPDATE_METHOD = sq.UPDATE_METHOD.CHANGE_MERGE
    car_name = (sq.TEXT_Sqlite, not None)
    car_type = (sq.TEXT_Sqlite, not None)

    @classmethod
    def Constraint(cls): 
        cls.PRIMARY = [(cls.car_name, cls.car_type)]


class carName(sq.SqTable, metaclass=sq.TableMeta):
    """此表用于存储车信息"""
    UPDATE_METHOD = sq.UPDATE_METHOD.CHANGE_MERGE

    car_id = (sq.INT_Sqlite, not None)
    # 车型编号
    car_name = (sq.TEXT_Sqlite, not None)
    # 车型名称
    carP_id = (sq.INT_Sqlite, not None)
    # 车品牌编号
    carP_name = (sq.INT_Sqlite, not None)
    # 车品牌名
    carCompany_id = (sq.INT_Sqlite, not None)
    # 车厂商编号
    carCompany_name = (sq.INT_Sqlite, not None)
    # 车厂商名

    @classmethod
    def Constraint(cls):
        cls.PRIMARY = [cls.car_id]
        cls.UNIQUE = [cls.car_name]


class carSell(sq.SqTable, metaclass=sq.TableMeta):
    UPDATE_METHOD = sq.UPDATE_METHOD.CHANGE_MERGE

    car_number = (sq.INT_Sqlite, not None)
    # 卖出数量
    car_name = (sq.TEXT_Sqlite, not None)
    # 车型名称
    sell_time = (sq.TEXT_Sqlite, not None)
    # 日期

    @classmethod
    def Constraint(cls):
        cls.PRIMARY = [(cls.car_name, cls.sell_time)]


class province(sq.SqTable, metaclass=sq.TableMeta):
    """此表用于存储省份信息"""
    UPDATE_METHOD = sq.UPDATE_METHOD.CHANGE_MERGE

    area_name = (sq.TEXT_Sqlite, not None)
    # 地区名
    province_name = (sq.TEXT_Sqlite, not None)
    # 省份名
    province_id = (sq.INT_Sqlite, not None)
    # 省id

    @classmethod
    def Constraint(cls):
        cls.PRIMARY = [cls.province_id]
        cls.UNIQUE = [cls.province_name]


class Sellall(sq.SqTable, metaclass=sq.TableMeta):
    """此表用于存储各个省总的汽车的销售情况"""
    UPDATE_METHOD = sq.UPDATE_METHOD.CHANGE_MERGE

    EnergyEcharts = (sq.TEXT_Sqlite, not None)
    # 能源类型
    DisplacementEcharts = (sq.TEXT_Sqlite, not None)
    # 排放量
    FactoryEcharts = (sq.TEXT_Sqlite, not None)
    # （国产还是合资）
    LevelEcharts = (sq.TEXT_Sqlite, not None)
    # 级别（SUV，轿车等）
    PriceEcharts = (sq.TEXT_Sqlite, not None)
    # 价格区间
    time = (sq.TEXT_Sqlite, not None)
    # 日期
    number = (sq.INT_Sqlite, not None)
    # 卖出数量
    province_id = (sq.INT_Sqlite, not None)
    # 省id

    @classmethod
    def Constraint(cls):
        pass


class SellAllWithProvince(sq.SqTable, metaclass=sq.TableMeta):
    UPDATE_METHOD = sq.UPDATE_METHOD.CHANGE_MERGE

    area_name = (sq.TEXT_Sqlite)
    # 地区名
    province_name = (sq.TEXT_Sqlite)
    # 省份名
    province_id = (sq.INT_Sqlite)
    # 省id
    EnergyEcharts = (sq.TEXT_Sqlite)
    # 能源类型
    DisplacementEcharts = (sq.TEXT_Sqlite)
    # 排放量
    FactoryEcharts = (sq.TEXT_Sqlite)
    # （国产还是合资）
    LevelEcharts = (sq.TEXT_Sqlite)
    # 级别（SUV，轿车等）
    PriceEcharts = (sq.TEXT_Sqlite)
    # 价格区间
    time = (sq.TEXT_Sqlite)
    # 日期
    number = (sq.INT_Sqlite)
    # 卖出数量

    @classmethod
    def Constraint(cls):
        cls.PRIMARY = [(cls.province_id, cls.EnergyEcharts, cls.DisplacementEcharts,
                        cls.FactoryEcharts, cls.LevelEcharts, cls.PriceEcharts, cls.time)]
